import api from '@/api/index.js';


export default async function followAction({request, params}) {
    const {username} = params;
    const {method} = request;
    switch (method) {
        case "POST": // 添加关注
            const followResponse = await api.user.follow(username)
            if (followResponse && followResponse.status !== 1) {
                throw new Error(followResponse.message) // 给错误页面捕获
            }
            return followResponse.data
        case "DELETE":

            const unfollowResponse = await api.user.unfollow(username)
            if (unfollowResponse && unfollowResponse.status !== 1) {
                throw new Error(unfollowResponse.message) // 给错误页面捕获
            }
            return unfollowResponse.data

        default:
            break;
    }


}


